/*
 *  Copyright 2020-2021 Li Fei
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.pengshun.modules.api.coal.service.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import com.pengshun.modules.api.coal.validator.*;
import com.pengshun.modules.common.ReslutView;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author lifei
 * @description /
 * @date 2020-11-12
 **/
@Data
public class MerchantCoalDto implements Serializable {

    @JsonView({ReslutView.aView.class})
    @NotNull(message = "id不能为空", groups = {First.class})
    private Long id;
    @NotNull(message = "id不能为空", groups = { Fourth.class})
    @JsonView({ReslutView.aView.class})
    private Long merchantCoalId;
    private Long userId;

    @JsonView({ReslutView.bView.class, ReslutView.aView.class})
    private String merchantName;

    @JsonView({ReslutView.bView.class, ReslutView.aView.class})
    private Long merchantId;

    @JsonView({ReslutView.bView.class, ReslutView.aView.class})
    @NotNull(message = "mineMouthId不能为空", groups = {Second.class})
    private Long mineMouthId;

    @JsonView(ReslutView.aView.class)
    @NotNull(message = "mineMouthName不能为空", groups = {Second.class})
    private String mineMouthName;

    private String isTax;

    private String detailAddress;

    private BigDecimal lngX;

    private BigDecimal latY;

    private Long categoryId;

    private String categoryName;


    @ApiModelProperty(value = "煤炭种类名称")
    private String coalCategoryName;

    @ApiModelProperty(value = "煤炭种类Id")
    private Long coalCategoryId;

    @JsonView({ReslutView.bView.class, ReslutView.aView.class})
    private Long coalId;

    @JsonView({ReslutView.aView.class, ReslutView.bView.class})
    @NotNull(message = "coalName不能为空", groups = {Second.class})
    private String coalName;


    @JsonView({ReslutView.aView.class})
    private Integer status;

    @JsonView({ReslutView.aView.class, ReslutView.bView.class})
    @NotNull(message = "sellPrice不能为空", groups = {Second.class})
    @NotNull(message = "价格不能为空", groups = {Sixth.class})
    @Min(value = 1,groups = Sixth.class,message ="请填写1-9999的价格")
    @Max(value = 9999,groups = Sixth.class,message ="请填写1-9999的价格")
    private BigDecimal sellPrice;

    @NotNull(message = "coalNumber不能为空", groups = {Second.class})
    @Min(value = 1,groups = Sixth.class,message ="请填写1-999999的数量")
    @Max(value = 999999,groups = Sixth.class,message ="请填写1-999999的数量")
    private BigDecimal coalNumber;
    private BigDecimal releaseNumber;

    private Integer  lowNumber;

    //产地
    private String producingArea;
    //交割地
    private String delivery;
    private String deliveryId;
    private String deliveryWay;
    //煤炭工艺
    private String coalTechnologyName;
    //煤炭工艺编码
    private String coalTechnologyCode;
    //结束日期
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date overTime;
    @JsonView(ReslutView.aView.class)
    private String coalPic;
    private String coalPicTwo;
    private String coalPicThree;
    @JsonView(ReslutView.aView.class)
    //发热量
    private String coalCalorific;

    private Integer lookNumber;

    @ApiModelProperty(value = "含硫量")
    @Min(value = 0,groups = Sixth.class,message ="请填写0-10的含硫量" )
    @Max(value = 10,groups = Sixth.class,message ="请填写0-10含硫量")
    private String allSulphur;


    @ApiModelProperty(value = "干基灰分")
    @Min(value = 0,groups = Sixth.class,message ="请填写0-50的干基灰分" )
    @Max(value = 50,groups = Sixth.class,message ="请填写0-50的干基灰分")
    private String serchHuifen;

    private BigDecimal volatilization;
    @JsonView(ReslutView.aView.class)
    @NotNull(message = "全水不能为空", groups = {Sixth.class})
    @Min(value = 0,groups = Sixth.class,message ="请填写0-50的全水" )
    @Max(value = 50,groups = Sixth.class,message ="请填写0-50的全水")
    private String wholeWater;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date laboratoryTime;
    @ApiModelProperty(value = "化验单图片")
    private String laboratoryBillPic;
    @ApiModelProperty(value = "化验单单位")
    private String laboratoryCompany;
    @ApiModelProperty(value = "联系人")
    private String linkman;
    @ApiModelProperty(value = "联系人电话")
    private String linkmanPhone;

    @Min(value = 0,groups = Sixth.class,message ="请填写0-10的内水" )
    @Max(value = 10,groups = Sixth.class,message ="请填写0-10的内水")
    private String nsValue;
    @Min(value = 0,groups = Sixth.class,message ="请填写0-50的空干基挥发" )
    @Max(value = 50,groups = Sixth.class,message ="请填写0-50的空干基挥发")
    private String kfValue;
    @Min(value = 0,groups = Sixth.class,message ="请填写0-50的收到基挥发" )
    @Max(value = 50,groups = Sixth.class,message ="请填写0-50的收到基挥发")
    private String sfValue;
    @Min(value = 0,groups = Sixth.class,message ="请填写0-50的干燥无灰基挥发" )
    @Max(value = 50,groups = Sixth.class,message ="请填写0-50的干燥无灰基挥发")
    private String gfValue;
    @Min(value = 0,groups = Sixth.class,message ="请填写0-10的焦渣特征" )
    @Max(value = 10,groups = Sixth.class,message ="请填写0-10的焦渣特征")
    private String jzValue;
    @Min(value = 0,groups = Sixth.class,message ="请填写0-100的固定碳" )
    @Max(value = 100,groups = Sixth.class,message ="请填写0-100的固定碳")
    private String gtValue;
    @Min(value = 2000,groups = Sixth.class,message ="请填写2000-10000的空干基高位" )
    @Max(value = 10000,groups = Sixth.class,message ="请填写2000-10000的空干基高位")
    private String kwValue;
    @Min(value = 2000,groups = Sixth.class,message ="请填写2000-10000的收到基低位" )
    @Max(value = 10000,groups = Sixth.class,message ="请填写2000-10000的收到基低位")
    private String swValue;
    @JsonView({ReslutView.aView.class, ReslutView.bView.class})
    private String priceUnit;
    private Integer issueStatus;
    @JsonView(ReslutView.aView.class)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date createTime;

    private String creatBy;

    private Date updateTime;

    private String updateBy;

    private String categoryCode;

    private String remark;

    private Integer isShow;

    private BigDecimal coalPrice;

    @Column(name = "issue_time")
    @ApiModelProperty(value = "发布时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
    private Date issueTime;

    @JsonView(ReslutView.aView.class)
    private String sulphurContent;

    @JsonView(ReslutView.bView.class)
    private List<MerchantCoalInfoDto> merchantCoalInfos;

    @NotNull(message = "coalIds不能为空", groups = {Third.class})
    private String coalIds;

    public String getWholeWater() {
        wholeWater = wholeWater == null ? "0%" : wholeWater;
        return wholeWater;
    }

    public String getSulphurContent() {
        sulphurContent = sulphurContent == null ? "0%" : sulphurContent;
        return sulphurContent;
    }

    public Long getMerchantCoalId() {

        return id==null?merchantCoalId:id;
    }

}